<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib  prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib  prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="redis" uri="http://www.shopjsp.com/redisTag/functions" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="basePath" value="${redis:getSysConfig('base_path_back')}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>入驻店铺信息</title>
	<jsp:include page="../../util/import.jsp"/>
	<script type="text/javascript">
        $(function(){

            var $tt= $("#tt").bootstrapTable({
                url: '${basePath}/back/enterShopInfo/listShopInfo.sjson ',        				/**请求后台的URL（*）**/
                method: 'post',                        /**请求方式（*）**/
                contentType: "application/x-www-form-urlencoded",
                dataType: "json",
                toolbar: '#toolbar',               	    /**工具按钮用哪个容器**/
                striped: true,                      	/**是否显示行间隔色**/
                cache: false,                       	/**是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）**/
                pagination: true,                   	/**是否显示分页（*）**/
                sortable: false,                    	/**是否启用排序**/
                sortOrder: "asc",                   	/**排序方式**/
                queryParamsType: '',
                sidePagination: "server",           	/**分页方式：client客户端分页，server服务端分页（*）**/
                pageNumber: 1,
                pageSize:10,							/**初始化加载第一页，默认第一页**/
                pageList: [5,10, 25, 50],        	    /**可供选择的每页的行数（*）**/
                search: false,                       	/**是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大**/
                strictSearch: true,
                showColumns: true,                  	/**是否显示所有的列**/
                showRefresh: true,                  	/**是否显示刷新按钮**/
                minimumCountColumns: 2,             	/**最少允许的列数**/
                clickToSelect: true,                	/**是否启用点击选中行**/
                uniqueId: "shopInfoId",              	/**每一行的唯一标识，一般为主键列**/
                singleSelect  : false,                   /** 单选checkbox**/
                showToggle:false,                    	/**是否显示详细视图和列表视图的切换按钮**/
                cardView: false,                    	/**是否显示详细视图**/
                detailView: false,                  	/**是否显示父子表**/
                columns: [
                    {checkbox: true},
                    {field: 'Number', title: '编号',align: 'center',valign: 'middle',width:'50px',
                        formatter: function (value, row, index) {
                            var page = $tt.bootstrapTable("getPage");
                            return page.pageSize * (page.pageNumber - 1) + index + 1;
                        }
                    },
                    {field: 'customerName',title: '店铺账号',align: 'center',valign: 'middle',
                        formatter:function(value,row,index){
                            var  a_html = '<a data-toggle="modal" data-target="#detailModal" href="#" mce_href="#" onclick="detailInfo('+row.shopInfoId+')">' + value + '</a>';
                            return a_html;
                        }
                    },
                    {field:"shopName",title:"店铺名称",align: 'center',valign: 'middle'},
                    {field:"shopCategoryName",title:"店铺分类名称",align: 'center',valign: 'middle'},
                    {field:"mainProduct",title:"主要销售产品",align: 'center',valign: 'middle'},
                    {field:"isPass",title:"审核状态",align: 'center',valign: 'middle',
                        formatter:function(value,row,index){
                            if(value==3){
                                return"<font class='color_001'>已通过</font>";
                            }
                            if(value==2){
                                return"<font class='color_002'>未通过</font>";
                            }
                            if(value==1){
                                return "<font class='color_003'>待审核</font>";
                            }
                        }
                    },
                    {field:"isClose",title:"是否关闭",align: 'center',valign: 'middle',
                        formatter:function(value,row,index){
                            if(value==0){
                                return"<font class='color_001'>未关闭</font>";
                            }else{
                                return"<font class='color_002'>已关闭</font>";
                            }
                        }
                    },
                    {field:"verifier",title:"店铺审核人",align: 'center',valign: 'middle'}
                ],
                queryParams: function (params) {
                    /**特别说明，返回的参数的值为空，则当前参数不会发送到服务器端,这种指定请求参数的方式和datatables控价类似**/
                    params.shopName = $("#q_shopName").val();
                    params.customerName = $("#q_customerName").val();
                    params.isClose = $("#q_isClose").val();
                    params.isPass = $("#q_isPass").val();
                    params.shopCategoryId = $("#q_shopCategoryId").val();
                    params.shopInfoType =2;
                    params.currentPage=params.pageNumber;
                    return params;
                }
            });
        });

        /**
         * 升级为自营店铺
         */
        <shiro:hasPermission name="back_gotoEnterShopInfoPage_upGrade">
        function upGrade(){
            /**获取选中行的id**/
            var selectedRow= $("#tt").bootstrapTable('getSelections');
            if(selectedRow.length>0){
                var ids="";
                for(var i=0;i<selectedRow.length;i++){
                    if(i==selectedRow.length-1)ids+=selectedRow[i].shopInfoId;
                    else ids+=selectedRow[i].shopInfoId+",";
                }
                showConfirm("你确定要升级为自营店铺吗?", function() {
                    $.ajax({
                        type: "POST",dataType: "JSON",
                        url: "${basePath}/back/enterShopInfo/upGradeSelfSupportShop.sjson",
                        data: {shopInfoIds:ids},
                        success: function(data) {
                            if (data.success == true) {
                                showMsg("升级成功！");
                                $("#tt").bootstrapTable('refresh');
                            }else{
                                showMsg("升级失败！");
                            }
                        }
                    });
                });
            }else {
                showMsg("请选择至少一行记录！");
            }
        }
        </shiro:hasPermission>

        /**批量开启**/
		<shiro:hasPermission name="back_gotoEnterShopInfoPage_batchOpen">
        function batchOpen(){
            /**获取选中行的id**/
            var selectedRow = $("#tt").bootstrapTable('getSelections');
            if(selectedRow.length>0){
                var ids="";
                for(var i=0;i<selectedRow.length;i++){
                    if(i==selectedRow.length-1)ids+=selectedRow[i].shopInfoId;
                    else ids+=selectedRow[i].shopInfoId+",";
                }
                $.ajax({
                    type: "POST",dataType: "JSON",
                    url: "${basePath}/back/enterShopInfo/saveOrUpdateIsClose.sjson",
                    data: {shopInfoIds:ids,isClose:0},
                    success: function(data) {
                        if (data.success == true) {
                            $("#tt").bootstrapTable('refresh');
                        }
                    }
                });
            }else {
                showMsg("请选择至少一行记录！");
            }
        }
		</shiro:hasPermission>

        /**批量关闭**/
		<shiro:hasPermission name="back_gotoEnterShopInfoPage_batchClose">
        function batchClose(){
            /**获取选中行的id**/
            var selectedRow = $("#tt").bootstrapTable('getSelections');
            if(selectedRow.length>0){
                var ids="";
                for(var i=0;i<selectedRow.length;i++){
                    if(i==selectedRow.length-1)ids+=selectedRow[i].shopInfoId;
                    else ids+=selectedRow[i].shopInfoId+",";
                }
                $.ajax({
                    type: "POST",dataType: "JSON",
                    url: "${basePath}/back/enterShopInfo/saveOrUpdateIsClose.sjson",
                    data: {shopInfoIds:ids,isClose:1},
                    success: function(data) {
                        if (data.success == true) {
                            $("#tt").bootstrapTable('refresh');
                        }
                    }
                });
            }else {
                showMsg("请选择至少一行记录！");
            }
        }
		</shiro:hasPermission>

        /**跳转到店铺内商品列表页**/
		<shiro:hasPermission name="back_gotoEnterShopInfoPage_showProduct">
        function queryShopProduct(){
            /**获取选中行的id**/
            var selectedRow= $("#tt").bootstrapTable('getSelections');
            if(selectedRow.length==1){
                location.href="${basePath}/back/enterShopInfo/gotoEnterShopProductListPage.inhtm?shopInfoId="+selectedRow[0].shopInfoId;
            }else{
                showMsg("请选择一行记录！");
            }
        }
		</shiro:hasPermission>

        /**跳转到店铺内部分类列表页**/
		<shiro:hasPermission name="back_gotoEnterShopInfoPage_maintainShopProCategery">
        function editShopProCategory(){
            /**获取选中行的id**/
            var selectedRow= $("#tt").bootstrapTable('getSelections');
            if(selectedRow.length==1){
                location.href="${basePath}/back/selfSupportShopProCategory/gotoSelfSupportShopProCategory.inhtm?shopInfoId="+selectedRow[0].shopInfoId;
            }else{
                showMsg("请选择一行记录！");
            }
        }
		</shiro:hasPermission>

        /**跳转到店铺客服列表页**/
		<shiro:hasPermission name="back_gotoEnterShopInfoPage_maintainShopService">
        function editShopService(){
            /**获取选中行的id**/
            var selectedRow= $("#tt").bootstrapTable('getSelections');
            if(selectedRow.length==1){
                location.href="${basePath}/back/customerService/gotoInStoreCustomerService.inhtm?shopInfoId="+selectedRow[0].shopInfoId;
            }else{
                showMsg("请选择一行记录！");
            }
        }
        </shiro:hasPermission>

	</script>
</head>

<body>

<div class="panel-body" id="customer-main-panel">
	<!-- 查询条件 -->
	<div class="panel panel-default">
		<div class="panel-heading">入驻店铺查询</div>
		<div class="panel-body">
			<form id="qform" class="form-horizontal">
				<div class="form-group" style="margin-top:15px">
					<div class="col-sm-3">
						<div class="input-group input-group-sm">
							<span class="input-group-addon">店铺账号</span>
							<input type="text" class="form-control" id="q_customerName" name="customerName" placeholder="请输入店铺账号"/>
						</div>
					</div>
					<div class="col-sm-3">
						<div class="input-group input-group-sm">
							<span class="input-group-addon">店铺名称</span>
							<input type="text" class="form-control" id="q_shopName" name="shopName" placeholder="请输入店铺名称"/>
						</div>
					</div>
					<div class="col-sm-2">
						<div class="input-group input-group-sm">
							<span class="input-group-addon">店铺类型</span>
							<select id="q_shopCategoryId" class="form-control">
								<option value="">--请选择--</option>
								<c:forEach items="${shopCategoryList}" var="sc">
									<option value="${sc.shopCategoryId}" >${sc.shopCategoryName}</option>
								</c:forEach>
							</select>
						</div>
					</div>
					<div class="col-sm-2">
						<div class="input-group input-group-sm">
							<span class="input-group-addon">是否关闭</span>
							<select id="q_isClose" class="form-control">
								<option value="">--请选择--</option>
								<option value="0">未关闭</option>
								<option value="1">已关闭</option>
							</select>
						</div>
					</div>
					<div class="col-sm-2">
						<div class="input-group input-group-sm">
							<span class="input-group-addon">审核状态</span>
							<select id="q_isPass" class="form-control">
								<option value="">--请选择--</option>
								<option value="1">待审核</option>
								<option value="2">未通过</option>
								<option value="3">已通过</option>
							</select>
						</div>
					</div>
					<div class="col-sm-2">
						<button type="button" id="btn_query" class="btn btn-primary">查询</button>
						<button type="reset" class="btn btn-success" id="resetBtn">重置</button>
					</div>
				</div>
			</form>
		</div>
	</div>

	<!-- 工具栏 -->
	<div id="toolbar" class="btn-group">
		<shiro:hasPermission name="back_gotoEnterShopInfoPage_check">
			<button id="btn_check" type="button" class="btn btn-default" data-toggle="modal" onclick="check()">
				<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>审核
			</button>
		</shiro:hasPermission>

		<shiro:hasPermission name="back_gotoEnterShopInfoPage_upGrade">
			<button id="btn_upGrade" type="button" class="btn btn-default" data-toggle="modal" onclick="upGrade()">
				<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>升级为自营店铺
			</button>
		</shiro:hasPermission>

		<shiro:hasPermission name="back_gotoEnterShopInfoPage_update">
			<button id="btn_edit" type="button" class="btn btn-default" data-toggle="modal" onclick="editShopInfo()">
				<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>修改入驻店铺信息
			</button>
		</shiro:hasPermission>

		<shiro:hasPermission name="back_gotoEnterShopInfoPage_maintainShopProCategery">
			<button id="btn_editShopCategory" type="button" class="btn btn-default" onclick="editShopProCategory()">
				<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>维护入驻店铺内部分类
			</button>
		</shiro:hasPermission>

		<shiro:hasPermission name="back_gotoEnterShopInfoPage_maintainShopService">
			<button id="btn_editShopService" type="button" class="btn btn-default" onclick="editShopService()">
				<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>维护店铺客服信息
			</button>
		</shiro:hasPermission>

		<shiro:hasPermission name="back_gotoEnterShopInfoPage_batchOpen">
			<button id="btn_open" type="button" class="btn btn-default" onclick="batchOpen()">
				<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>批量开启
			</button>
		</shiro:hasPermission>

		<shiro:hasPermission name="back_gotoEnterShopInfoPage_batchClose">
			<button id="btn_close" type="button" class="btn btn-default" onclick="batchClose()">
				<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>批量关闭
			</button>
		</shiro:hasPermission>

		<shiro:hasPermission name="back_gotoEnterShopInfoPage_showProduct">
			<button id="btn_queryShopProduct" type="button" class="btn btn-default" onclick="queryShopProduct()">
				<span class="glyphicon glyphicon-search" aria-hidden="true"></span>查看店铺商品
			</button>
		</shiro:hasPermission>
	</div>

	<!-- 渲染的table -->
	<table id="tt"></table>

	<!-- 添加或者修改 -->
	<jsp:include page="addOrEdit.jsp" />
	<!-- 详情页 -->
	<jsp:include page="detail.jsp" />
	<!-- 审核页面 -->
	<jsp:include page="isPassShopInfo.jsp" />

</div>

</body>
</html>
